package org.springframework.boot;

import org.springframework.core.SpringVersion;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.io.DefaultResourceLoader;

import java.util.Map;

/**
 * @author shiminghui
 * @date 2025/5/8 16:27
 * @description: TODO
 */
public class Step7 {
    public static void main(String[] args) {

        // 第七步就是打印spring的logo和版本号
        SpringApplication application = new SpringApplication();

        ApplicationEnvironment environment = new ApplicationEnvironment();

        SpringApplicationBannerPrinter printer =
                new SpringApplicationBannerPrinter(new DefaultResourceLoader(), new SpringBootBanner());

        // 当然你也可以输出自己的banner,
        // 测试文字
//        environment.getPropertySources()
//                .addLast(new MapPropertySource("custom", Map.of("spring.banner.location","banner1.txt")));
        // 测试图片
        environment.getPropertySources()
                .addLast(new MapPropertySource("custom", Map.of("spring.banner.image.location", "OIP-C.jpg")));

        System.out.println(SpringVersion.getVersion());

        printer.print(environment, Step7.class, System.out);

    }
}
